//
//  BaseModel.m
//  TestApplication
//
//  Created by 曹曹 on 16/8/26.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel

- (instancetype)initWithDictionary:(NSDictionary *)dictionary {
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dictionary];
    }
    return self;
}

+ (BaseModel *)modelWithDictionary:(NSDictionary *)dictionary {
    return [[self alloc] initWithDictionary:dictionary];
}

- (__kindof NSArray *)arrayWithClass:(Class)clasz value:(id)value {
    NSMutableArray *modelArr = [NSMutableArray array];
    for (NSDictionary *dictionary in value) {
        BaseModel *model = [clasz modelWithDictionary:dictionary];
        [modelArr addObject:model];
    }
    return modelArr;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {}

- (void)setNilValueForKey:(NSString *)key {}

- (id)valueForUndefinedKey:(NSString *)key {
    return nil;
}

@end
